﻿<bc:SLBC x:Class="SLS.Presentation.EventLogExplorer"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
         xmlns:ucc="clr-namespace:SLS.DataBase;assembly=CLSDB"
         xmlns:sys="clr-namespace:System;assembly=mscorlib"
         xmlns:exc="clr-namespace:SLS.Controls;assembly=CLSControls"
         xmlns:bc="clr-namespace:SLS.Base;assembly=CLSBase"
         xmlns:events="clr-namespace:SLS.ExClassLib.Events;assembly=CLSEvents"
         xmlns:converters="clr-namespace:SLS.ExClassLib.Converters;assembly=Converters"          
         >
    <bc:SLBC.Resources>
        <ObjectDataProvider x:Key="LogLevelData"
                            MethodName="GetValues"
                            ObjectType="{x:Type sys:Enum}">
            <ObjectDataProvider.MethodParameters>
                <x:Type TypeName="events:MessageEventType" />
            </ObjectDataProvider.MethodParameters>
        </ObjectDataProvider>
    </bc:SLBC.Resources>
    <Grid HorizontalAlignment="Stretch"
          VerticalAlignment="Stretch">
        <Grid.RowDefinitions>
            <RowDefinition Height="28" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <DockPanel Grid.Row="0">
            <StackPanel Orientation="Horizontal">
                <TextBlock VerticalAlignment="Center"
                           Margin="5">View:</TextBlock>
                <ComboBox Name="cbLogLevel"
                          IsReadOnly="True"
                          SelectedIndex="3"
                          Margin="1"
                          ItemsSource="{Binding Source={StaticResource LogLevelData}}"
                          SelectedItem="{Binding Path=Workspace.LogLevel, Mode=TwoWay}" />
                <Button Click="BtnClear_Click"
                                     ToolTip="Clear all the logs"
                                     >Clear</Button>
            </StackPanel>
        </DockPanel>
        <DataGrid Grid.Row="1"
                  Name="dataGridLogEvent"
                  AutoGenerateColumns="False"
                  EnableRowVirtualization="True"
                  EnableColumnVirtualization="True"
                  CanUserSortColumns="True">
            <!-- Column definition -->
            <DataGrid.Columns>
                <DataGridTemplateColumn Header=""
                                        Width="SizeToCells">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Image Source="{Binding Type, Mode=OneWay, Converter={x:Static converters:LogTypeToImageConverter.Instance}}"></Image>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTextColumn Header="Time"
                                    Binding="{Binding When, Mode=OneWay}"
                                    Width="SizeToCells" />
                <DataGridTextColumn Header="Where"
                                    Binding="{Binding Where, Mode=OneWay}"
                                    Width="*" />
                <DataGridTextColumn Header="Details"
                                    Binding="{Binding Details, Mode=OneWay}"
                                    Width="*" />
            </DataGrid.Columns>
        </DataGrid>
    </Grid>
</bc:SLBC>
